/*
 * @Author: kincaid
 * @Date: 2021-08-23 01:27:49
 * @LastEditors: kincaid
 * @LastEditTime: 2021-08-24 00:00:43
 * @Description: file content
 */
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  console.log(event)
  console.log(context)
  // let userid;
  let list = event.list;
   db.collection('order').doc('8937eaa9612271b105d1200f6efb5b7a').get({
    success: function(res) {
      console.log(res.data)
    }
  })
  list.forEach(v => {
    console.log(v.id);
    db.collection('order').where({
      oid: v.id
    })
    // .get({
    //   success: function(res) {
    //     console.log(res.data)
    //   }
    // })
    .update({
      // data 传入需要局部更新的数据
      data: {
        sale: v.sale
     }
    })
  });
   
    
  // console.log("res33333333333333")
  // console.log(res)
  // if(res){
    return {
      status: 'ok'
    }
  // }
 
  
}
